package com.bykj.taketurns.findfragment.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bykj.taketurns.R;
import com.bykj.taketurns.findfragment.activity.LevelThreeActivity;
import com.bykj.taketurns.findfragment.bean.SecondaryVideoBean;

import java.util.List;


/**
 * Created by Administrator on 2017/8/14.
 */

public class SecondaryVideoAdapter extends RecyclerView.Adapter<SecondaryVideoAdapter.ViewHolder> {
    private Context context;
    private List<SecondaryVideoBean.OneListBean> list;

    public SecondaryVideoAdapter(Context context, List<SecondaryVideoBean.OneListBean> oneList) {
        this.context = context;
        this.list = oneList;

    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.sec_video_item, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position) {
        Glide.with(context).load(list.get(position).getStoryVideo().getSvimg()).into(holder.iv_secondary_image_video);
        holder.tv_secondary_title_video.setText(list.get(position).getTname());
        holder.tv_secondary_sum_video.setText(list.get(position).getVideoAllCount() + "");
        holder.tv_secondary_name_video.setText(list.get(position).getStoryVideo().getUnickname());
        holder.tv_secondary_planting_video.setText(list.get(position).getJcCount() + "次");
        holder.tv_secondary_like_video.setText(list.get(position).getStoryVideo().getSvbrowse() + "次");
        holder.tv_secondary_review_video.setText(list.get(position).getCountPing() + "");
        holder.tv_secondary_renewal_video.setText(list.get(position).getStoryVideo().getSvaddtime());
        holder.btn_sec_video.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, LevelThreeActivity.class);
                intent.putExtra("IF", true);
                intent.putExtra("tid",list.get(position).getTid());
                intent.putExtra("title",list.get(position).getTname());
                context.startActivity(intent);

            }
        });
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        RelativeLayout btn_sec_video;
        ImageView iv_signboard_video;
        ImageView iv_secondary_image_video;
        TextView tv_secondary_title_video;
        TextView tv_secondary_name_video;
        TextView tv_secondary_planting_video;
        TextView tv_secondary_like_video;
        TextView tv_secondary_review_video;
        TextView tv_secondary_renewal_video;
        TextView tv_secondary_sum_video;
        public ViewHolder(View view) {
            super(view);

            btn_sec_video = view.findViewById(R.id.btn_sec_video);
            iv_signboard_video = view.findViewById(R.id.iv_signboard_video);
            iv_secondary_image_video = view.findViewById(R.id.iv_secondary_image_video);
            tv_secondary_title_video = view.findViewById(R.id.tv_secondary_title_video);
            tv_secondary_name_video = view.findViewById(R.id.tv_secondary_name_video);
            tv_secondary_planting_video = view.findViewById(R.id.tv_secondary_planting_video);
            tv_secondary_like_video = view.findViewById(R.id.tv_secondary_like_video);
            tv_secondary_review_video = view.findViewById(R.id.tv_secondary_review_video);
            tv_secondary_renewal_video = view.findViewById(R.id.tv_secondary_renewal_video);
            tv_secondary_sum_video = view.findViewById(R.id.tv_secondary_sum_video);
        }
    }
}
